using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace ICP_MS.Plugin.Experiment;

public class FormSeqConfigSelect : Form
{
	private List<ExperimentDatasSeq> experimentDatasSeqs;

	public ExperimentDatasSeq experimentDatasSeqSelected;

	private IContainer components = null;

	private ListView listView1;

	private Button btnAdd;

	private Button btnCancel;

	public FormSeqConfigSelect()
	{
		InitializeComponent();
	}

	public void SetParams(List<ExperimentDatasSeq> experimentDatasSeqsInForm)
	{
		experimentDatasSeqs = experimentDatasSeqsInForm;
	}

	private void FormSeqConfigSelect_Load(object sender, EventArgs e)
	{
		if (experimentDatasSeqs == null || experimentDatasSeqs.Count <= 0)
		{
			return;
		}
		foreach (ExperimentDatasSeq experimentDatasSeq in experimentDatasSeqs)
		{
			listView1.Items.Add(new ListViewItem(experimentDatasSeq.Name));
		}
	}

	private void btnAdd_Click(object sender, EventArgs e)
	{
		if (listView1.SelectedItems != null && listView1.SelectedItems.Count > 0)
		{
			experimentDatasSeqSelected = experimentDatasSeqs[listView1.SelectedItems[0].Index];
			base.DialogResult = DialogResult.OK;
		}
		else
		{
			MessageBox.Show(Lang.Txt("AddFormSeqConfigSelect.SelectMethod"), Lang.Txt("AddFormSeqConfigSelect.Warn"), MessageBoxButtons.OK);
		}
	}

	private void btnCancel_Click(object sender, EventArgs e)
	{
		base.DialogResult = DialogResult.Cancel;
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.listView1 = new System.Windows.Forms.ListView();
		this.btnAdd = new System.Windows.Forms.Button();
		this.btnCancel = new System.Windows.Forms.Button();
		base.SuspendLayout();
		this.listView1.FullRowSelect = true;
		this.listView1.HideSelection = false;
		this.listView1.Location = new System.Drawing.Point(12, 12);
		this.listView1.MultiSelect = false;
		this.listView1.Name = "listView1";
		this.listView1.Size = new System.Drawing.Size(776, 258);
		this.listView1.TabIndex = 0;
		this.listView1.UseCompatibleStateImageBehavior = false;
		this.listView1.View = System.Windows.Forms.View.List;
		this.btnAdd.Location = new System.Drawing.Point(520, 293);
		this.btnAdd.Name = "btnAdd";
		this.btnAdd.Size = new System.Drawing.Size(126, 33);
		this.btnAdd.TabIndex = 1;
		this.btnAdd.Text = "添加";
		this.btnAdd.UseVisualStyleBackColor = true;
		this.btnAdd.Click += new System.EventHandler(btnAdd_Click);
		this.btnCancel.Location = new System.Drawing.Point(662, 293);
		this.btnCancel.Name = "btnCancel";
		this.btnCancel.Size = new System.Drawing.Size(126, 33);
		this.btnCancel.TabIndex = 1;
		this.btnCancel.Text = "取消";
		this.btnCancel.UseVisualStyleBackColor = true;
		this.btnCancel.Click += new System.EventHandler(btnCancel_Click);
		base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 15f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(800, 338);
		base.Controls.Add(this.btnCancel);
		base.Controls.Add(this.btnAdd);
		base.Controls.Add(this.listView1);
		base.Name = "FormSeqConfigSelect";
		this.Text = "方法序列列表";
		base.Load += new System.EventHandler(FormSeqConfigSelect_Load);
		base.ResumeLayout(false);
	}
}
